package com.my_musc_service.controller;

import com.my_musc_service.common.R;
import com.my_musc_service.entity.CommentLike;
import com.my_musc_service.service.CommentLikeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CommentLike)表控制层
 *
 * @author A.Dun
 * @since 2021-08-26 20:15:16
 */
@RestController
@RequestMapping("commentLike")
public class CommentLikeController {
    /**
     * 服务对象
     */
    @Resource
    private CommentLikeService commentLikeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public CommentLike selectOne(Integer id) {
        return this.commentLikeService.queryById(id);
    }


    @GetMapping("select")
    public R selectByCommentLike(CommentLike commentLike) {
        List<CommentLike> commentLikeList = this.commentLikeService.selectByCommentLike(commentLike);
        return R.ok().data("commentLikeList", commentLikeList);
    }

    @PostMapping("add")
    public R add(@RequestBody CommentLike commentLike){
        this.commentLikeService.insert(commentLike);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R delete(@RequestBody CommentLike commentLike){
        this.commentLikeService.deleteByCommentLike(commentLike);
        return R.ok();
    }

}
